#include "PrecompiledHeaders.h"
#include "Keyboard.h"

Keyboard::Keyboard(OIS::Keyboard *k) : UserControlledInputDevice()
{
    keyboard = k;
    x_factor = Constants::MAX_ANGLE.valueRadians() / 100;
    y_factor = Constants::MAX_ANGLE.valueRadians() / 100;
    x = y = 0;
}

Ogre::Radian Keyboard::getX()
{
    if(isKeyDown(OIS::KC_LEFT)) x = x - Ogre::Radian(1);
    if(isKeyDown(OIS::KC_RIGHT)) x = x + Ogre::Radian(1);
    if(x.valueRadians() >  100) x = Ogre::Radian( 100);
    if(x.valueRadians() < -100) x = Ogre::Radian(-100);
    return x;    
}

Ogre::Radian Keyboard::getY()
{
    if(isKeyDown(OIS::KC_UP)) y = y - Ogre::Radian(1);
    if(isKeyDown(OIS::KC_DOWN)) y = y + Ogre::Radian(1);
    if(y.valueRadians() >  100) y = Ogre::Radian( 100);
    if(y.valueRadians() < -100) y = Ogre::Radian(-100);
    return y;   
}


